package com.zxt.util;

import java.math.BigInteger;
import java.security.MessageDigest;


public class MD5util {
    public static String md5(String str){
        try {
            //1.获取消息摘要算法
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            byte[] bytes = str.getBytes("UTF-8");
            for (int i=0;i<bytes.length;i++){
                bytes[i]-=7;
            }
            //2.更新数据
            md5.update(bytes);
            //3.加密
            byte[] digest = md5.digest();
            //4.返回
            return new BigInteger(1,digest).toString(16);
        }catch (Exception e){
            e.printStackTrace();

        }
        return null;
    }

}
